<?php
if(!defined('ADMINPX') || !defined('ADMIN')) {
	exit('Access Denied');
}
$act=$_GET['act'];
$uid=$_GET['uid'];
$id=$_GET['id'];
$aa=$_GET['aa'];

if($act =='xg'){
$row=$db->get_one('user'," `uid` ='$uid'",'');
$user_renminbi   =Bingz_renminbi($uid);
if($row[renminbi_zt] == '0'){ 
	  $hyzt='<a href="admin.php?action=user_renminbi&act=djok&uid='.$row[uid].'">冻结</a>'; 
}else{ 
		$hyzt='<a href="admin.php?action=user_renminbi&act=jdok&uid='.$row[uid].'">解冻</a> - 
	         <a href="admin.php?action=user_renminbi&act=sdjdok&uid='.$row[uid].'">深度解冻</a>'; 
}
echo <<<end
<div class="admin">管理会员资金<br/></div>
<div class="admin_a">会员UID :$row[uid]</div>
<div class="admin_a">用 户 名 :$row[name]</div>
<div class="admin_a">人 民 币 :$user_renminbi  $hyzt</div>
<div class="admin_a">
<form method="POST" action="admin.php?action=user_renminbi&act=czok&uid=$row[uid]" enctype="multipart/form-data">
充值金额：
<input type="text" name="renminbi" value="0" size="10"/></br>
写入备注：
<input type="text" name="name" value="系统充值"  size="20"/></br>
支付密令：
<input type="password" name="pass" value=""  size="20"/></br>
<input class="submit" type="submit" value="提交" name="b1" />
</form></br></div>
<div class="admin_a">
<form method="POST" action="admin.php?action=user_renminbi&act=tcok&uid=$row[uid]" enctype="multipart/form-data">
提出金额：
<input type="text" name="renminbi" value="0" size="10"/></br>
写入备注：
<input type="text" name="name" value="系统扣除"  size="20"/></br>
支付密令：
<input type="password" name="pass" value=""  size="20"/></br>
<input class="submit" type="submit" value="提交" name="b1" />
</form></br></div>
end;

   $num_count=$db->num_rows('user_renminbi'," `uid` ='$uid'",'id');
   $list_num ="8";
   $num_start=page_num($list_num,$num_count);
   $sql_bbs  =$db->query('user_renminbi'," `uid` ='$uid' ORDER BY `id` DESC LIMIT ".$num_start." , ".$list_num." ",'');
   while($row_b=mysql_fetch_array($sql_bbs)){
   	$tsj=Bingz_time_f($row_b['time_a']);
echo<<<end
<div class="admin_a">
<b>备注</b>：<font color="0B04FB">{$row_b[content]}</font><br/>
<b>金额</b>：<font color="ff0000">{$row_b[renminbi_cz]}</font>      
<b>余额</b>：<font color="ff0000">{$row_b[renminbi]}</font><br/>
<b>状态</b>：<font color="ff0000">{$row_b[renminbi_ztname]}</font><br/>
<b>账单号</b>：{$row_b[name]}<br/>
<b>时间</b>：{$tsj}
</div>
end;
   }
echo $page=page_link($list_num,$num_count);

}else if($act =='djok'){
    	Bingz_management($uid,'renminbi','+0','管理员账号冻结','',$Bingz_renminbi_pass); 			  	
    	$db->update('user',array( 'renminbi_zt' => 1),"`uid` = '$uid'");    			  	
    	echo "提交成功<br/>";
    	echo "正在自动返回.......<br/><a href=\"admin.php?action=user_renminbi&act=xg&uid=$uid\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=user&act=xg&uid=$uid'>";
}else if($act =='jdok'){
    	$db->update('user',array( 'renminbi_zt' => '0'),"`uid` = '$uid'");
    	Bingz_management($uid,'renminbi','+0','管理员解除账号冻结','',$Bingz_renminbi_pass); 			  	
    	echo "提交成功<br/>";
    	echo "正在自动返回.......<br/><a href=\"admin.php?action=user_renminbi&act=xg&uid=$uid\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=user_renminbi&act=xg&uid=$uid'>";
}else if($act =='sdjdok'){
	    $row=$db->get_one('user'," `uid` ='$uid'",'');
    	$db->update('user',array( 'renminbi_zt' => 0),"`uid` = '$uid'");
    	$xzzhje=Bingz_renminbi_pass($row[renminbi]);
    	$zdmmm=date("YmdHis");
    	$db->insert('user_renminbi',array('id ' => 'NULL' ,'uid ' => $uid,'uip ' => $ip,'url ' => $url_b,'pass' => $xzzhje,'name' => $zdmmm,'type' => 2,'renminbi' => $row['renminbi'],'renminbi_yl' => $row['renminbi'],'renminbi_cz' => '+0','renminbi_ztsz' => '1','renminbi_ztname ' => '操作成功','content ' => '管理员解除账号冻结','votes' => 0,'time_a' => $time));
      echo "提交成功<br/>";
    	echo "正在自动返回.......<br/><a href=\"admin.php?action=user_renminbi&act=xg&uid=$uid\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=user_renminbi&act=xg&uid=$uid'>";
}else if($act =='czok'){
	    if($_POST[pass] != $Bingz_renminbi_pass){
	    	 echo "支付密令错误！<br/>";
    	}elseif($_POST[renminbi] < '1'){
	    	 echo "提交金额有误<br/>";
    	}elseif(Bingz_management($uid,'renminbi','+'.$_POST[renminbi],$_POST[name],'',$Bingz_renminbi_pass,'1','','','','','','1') > '0'){
	    	 echo "提交成功<br/>";
    	}else{
    	   echo "提交失败<br/>";
    	}	  	
    	echo "正在自动返回.......<br/><a href=\"admin.php?action=user_renminbi&act=xg&uid=$uid\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=user_renminbi&act=xg&uid=$uid'>";
}else if($act =='tcok'){
	    if($_POST[pass] != $Bingz_renminbi_pass){
	    	 echo "支付密令错误！<br/>";
    	}elseif($_POST[renminbi] < '1'){
	    	 echo "提交金额有误<br/>";
    	}elseif(Bingz_management($uid,'renminbi','-'.$_POST[renminbi],$_POST[name],'',$Bingz_renminbi_pass,'','','','','','','1') > '0'){
	    	 echo "提交成功<br/>";
    	}else{
    	   echo "提交失败<br/>";
    	}	  	
    	echo "正在自动返回.......<br/><a href=\"admin.php?action=user_renminbi&act=xg&uid=$uid\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=user_renminbi&act=xg&uid=$uid'>";
}else if($act =='zhao'){
      echo "<div class='admin' >会员银行账号绑定</div>";
      if($_GET['acti']=="save"){
      	 $row=$db->get_one('user_renminbi_zh'," `id` ='$id'",'');
      	 if($_POST[name] == '1'){
      	    $db->update('user_renminbi_zh',array( 'type' => '1' ),"`id`= '$id' ");
      		  Bingz_message_post('0',$row[uid],"你好！你绑定的$row[name_lx]账户$row[zh]绑定成功！");
      	 }else{
      		  $db->delete('user_renminbi_zh',"  `id` = '$id'");
      		  Bingz_message_post('0',$row[uid],"你好！你绑定的$row[name_lx]账户$row[zh]绑定失败！");
      	 }
    	echo "操作成功<br/>正在自动返回.......<br/><a href=\"admin.php?action=user_renminbi&act=zhao\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=user_renminbi&act=zhao'>";      	 
      }else{
           $sql_bbs  =$db->query('user_renminbi_zh',"`type` ='0' ORDER BY `id` ",'');
           while($row_c=mysql_fetch_array($sql_bbs)){
           	     $name=$user_class->user_name($row_c[uid]);
                 echo"<div class=\"admin_a\">所属用户：<a href=\"index.php?$Bingz_ml=user&uid=$row_c[uid]\">$name</a><br/>
                                             银行：$row_c[name_lx]<br/>
                                             户名：$row_c[name]<br/>
                                             账号：$row_c[zh]<br/>";
                 echo'<form method="POST" action="admin.php?action=user_renminbi&act=zhao&&acti=save&id='.$row_c[id].'">
                      审核:
                      <input type="radio" name="name" value="1" />通过绑定
                      <input type="radio" name="name" value="0" CHECKED/>绑定失败<br/>
                      <input class="submit" type="submit" name="B1" value="提交"/></form>
                      </div>';
           }
           if(!$db->get_one('user_renminbi_zh',"`type` ='0' ",'')){
   	          echo '<div class="admin_a">没有数据！</div>';
           }
      }
}else if($act =='lstix'){
   	       echo '<div class="admin_a"><a href="admin.php?action=user_renminbi&act=tix">返回提现</a></div>';
           echo "<div class='admin' >会员历史提现</div>";
$name=$_POST[mm];
echo  <<<end
<div class="admin_a">
<form method="POST" action="admin.php?action=user_renminbi&act=lstix" >
<input type="text" name="mm" value="$name" size="30" placeholder="uid" />
<input type="submit" value="查询" name="adminpost" />
</form>
</div>
end;
if($_POST[mm]){
           $num_count=$db->num_rows('user_renminbi',"`type` ='3' and `uid` = '$_POST[mm]' ",'id');
           $list_num ="10";
           $num_start=page_num($list_num,$num_count);
           $sql_bbs  =$db->query('user_renminbi',"`type` ='3' and `uid` = '$_POST[mm]' ORDER BY `id` DESC LIMIT ".$num_start." , ".$list_num." ",'');
}else{
           $num_count=$db->num_rows('user_renminbi',"`type` ='3' ",'id');
           $list_num ="10";
           $num_start=page_num($list_num,$num_count);
           $sql_bbs  =$db->query('user_renminbi',"`type` ='3' ORDER BY `id` DESC LIMIT ".$num_start." , ".$list_num." ",'');
}
           while($row_c=mysql_fetch_array($sql_bbs)){
           	     $renmin=$db->get_one('user_renminbi_zh',"`id` ='$row_c[votes]' ",'');
           	     $name=$user_class->user_name($row_c[uid]);
           	     $renminbi=explode("-",$row_c[renminbi_cz]);
           	     $sjz=Bingz_time($row_c[time_a]);
                 echo"<div class=\"admin_a\">所属用户：<a href=\"index.php?$Bingz_ml=user&uid=$row_c[uid]\">$name</a><br/>
                                             提现金额：$renminbi[1]  状态:<b>$row_c[renminbi_ztname]</b><br/>
                                             所选账号：$renmin[name_lx]($renmin[name])-<b>$renmin[zh]</b><br/>
                                             提现时间：$sjz<br/>
                                             </div>";
           }
           echo $page=page_link($list_num,$num_count);
           if(!$num_count){
   	          echo '<div class="admin_a">没有提现数据！</div>';
           }
}else if($act =='tix'){
   	  echo '<div class="admin_a"><a href="admin.php?action=user_renminbi&act=lstix">历史提现</a></div>';
      echo "<div class='admin' >会员提现管理</div>";
      if($_GET['acti']=="save"){
      	 $row=$db->get_one('user_renminbi'," `id` ='$id'",'');
      	 if($_POST[name] == '1'){
      		  $db->update('user_renminbi',array( 'renminbi_ztname' => '正在审核'),"`id` = '$id'");
      		  Bingz_message_post('0',$row[uid],"你好！你申请的提现金额(账单号$row[name])正在审核");
      	 }elseif($_POST[name] == '2'){
      		  $db->update('user_renminbi',array( 'renminbi_ztname' => '正在转账'),"`id` = '$id'");
      		  Bingz_message_post('0',$row[uid],"你好！你申请的提现金额(账单号$row[name])正在转账");
      	}elseif($_POST[name] == '3'){
      		  $db->update('user_renminbi',array( 'renminbi_ztname' => '转账成功', 'renminbi_ztsz' => '1'),"`id` = '$id'");
      		  Bingz_message_post('0',$row[uid],"你好！你申请的提现金额(账单号$row[name])转账成功");
      	      	   	     	     	   if(Bingz_config('sms_set_payment') == '1' ){
	   	                                    $email_set_reg_body=Bingz_config('sms_set_payment_body');
	   	                                    $email_set_reg_body=str_replace('{title}',$row[content],$email_set_reg_body);
	   	                                    $email_set_reg_body=str_replace('{number}',$row[name],$email_set_reg_body);
	   	                                    Bingz_sms_post($userrmb[mobile],$email_set_reg_body);
	   	                             }
      	 }elseif($_POST[name] == '4'){
      	 	  $renminbi=explode('-',$row[renminbi_cz]);
      		  if(Bingz_management($row[uid],'renminbi','+'.$renminbi[1],'提现失败('.$row[name].')返回金额','',$Bingz_renminbi_pass) > '0'){
      		     $db->update('user_renminbi',array( 'renminbi_ztname' => '提现失败', 'renminbi_ztsz' => '3'),"`id` = '$id'");
      		     Bingz_message_post('0',$row[uid],"你好！你申请的提现金额(账单号$row[name])提现失败");
      	    }
      	 }
    	echo "操作成功<br/>正在自动返回.......<br/><a href=\"admin.php?action=user_renminbi&act=tix\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=user_renminbi&act=tix'>";      	 
      }else{
           $sql_bbs  =$db->query('user_renminbi',"`type` ='3' and `renminbi_ztsz` ='2'  ORDER BY `id` ",'');
           while($row_c=mysql_fetch_array($sql_bbs)){
           	     $renmin=$db->get_one('user_renminbi_zh',"`id` ='$row_c[votes]' ",'');
           	     $name=$user_class->user_name($row_c[uid]);
           	     $renminbi=explode("-",$row_c[renminbi_cz]);
                 echo"<div class=\"admin_a\">所属用户：<a href=\"index.php?$Bingz_ml=user&uid=$row_c[uid]\">$name</a><br/>
                                             提现金额：$renminbi[1]<br/>
                                             所选账号：$renmin[name_lx]($renmin[name])-<b>$renmin[zh]</b><br/>";
                 echo'<form method="POST" action="admin.php?action=user_renminbi&act=tix&&acti=save&id='.$row_c[id].'">
                      状态:<b>'.$row_c[renminbi_ztname].'</b><br/>
                      <input type="radio" name="name" value="1" CHECKED/>正在审核<br/>
                      <input type="radio" name="name" value="2" CHECKED/>正在转账<br/>
                      <input type="radio" name="name" value="3" CHECKED/>转账成功<br/>
                      <input type="radio" name="name" value="4" CHECKED/>提现失败<br/>
                      <input class="submit" type="submit" name="B1" value="提交"/></form>
                      </div>';
           }
           if(!$db->get_one('user_renminbi',"`type` ='3' and `renminbi_ztsz` ='2' ",'')){
   	          echo '<div class="admin_a">没有提现数据！</div>';
           }
      }
}else{
echo  <<<end
<div class="admin_a">
<form method="POST" action="admin.php?action=user_renminbi" >
<input type="text" name="mm" value="$name" size="30" placeholder="uid" />
<input type="submit" value="快速查询" name="b1" />
</form>
</div>
end;
if($waw=@$db->get_one('user'," `uid` ='$_POST[mm]' ",'')){
       $num_count=$db->num_rows('user'," `uid` = '$waw[uid]'",'uid');
       $list_num ="10";
       $num_start=page_num($list_num,$num_count);
       $sql_bbs  =$db->query('user'," `uid` = '$waw[uid]' ORDER BY `uid` DESC LIMIT ".$num_start." , ".$list_num." ",'');
}elseif($aa=='hd'){
       $num_count=$db->num_rows('user',"1 ",'uid');
       $list_num ="10";
       $num_start=page_num($list_num,$num_count);
       $sql_bbs  =$db->query('user',"1 ORDER BY `renminbi` DESC LIMIT ".$num_start." , ".$list_num." ",'');
}elseif($aa=='old'){
       $num_count=$db->num_rows('user',"1 ",'uid');
       $list_num ="10";
       $num_start=page_num($list_num,$num_count);
       $sql_bbs  =$db->query('user',"1 ORDER BY `uid` LIMIT ".$num_start." , ".$list_num." ",'');
}else{
       $num_count=$db->num_rows('user'," ",'uid');
       $list_num ="10";
       $num_start=page_num($list_num,$num_count);
       $sql_bbs  =$db->query('user'," ORDER BY `uid` DESC LIMIT ".$num_start." , ".$list_num." ",'');
}
$ts=$db->num_rows('user'," ",'uid');
echo  <<<end
<div class="admin_a">
<a href="admin.php?action=user_renminbi"><b>倒序</b></a> -
<a href="admin.php?action=user_renminbi&aa=old&$see"><b>顺排</b></a> -
<a href="admin.php?action=user_renminbi&aa=hd&$see"><b>金额</b></a> -
<a href="admin.php?action=user_renminbi&act=tix">提现管理</a>
</div>
end;
while($row=mysql_fetch_array($sql_bbs)){
	$sjz=Bingz_time($row[time_a]);
	if($row[renminbi_zt] == '0'){ $hyzt='正常'; }else{ $hyzt='冻结'; }
	echo"<div class=\"admin_a\">UID($row[uid])
	<a href=\"admin.php?action=user&act=xg&uid=$row[uid]\">$row[name]</a> -
	<a href=\"admin.php?action=user_renminbi&act=xg&uid=$row[uid]\">管理金额</a><br/>";
echo  <<<end
人民币:<font color="ff0000">$row[renminbi] </font> ($hyzt)
<br/></div>
end;
}
echo $page=page_link($list_num,$num_count);
}
?>